<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>资金明细列表</title>
    <jsp:include page="../../head.jsp"/>
    <script type="text/javascript">
        var baseContextPathUrl_ = location.href.substr(0, location.href.indexOf("/", 9))
                                  + "<s:url value="/"/>";
    </script>
    <script type="text/javascript" src="<s:url value="/js/ajaxutil.js"/>"></script>
</head>
<script type="text/javascript">
    var allFundFinancialType = [["预付款/退款", "IN"], ["支出", "OUT"]];
    var allFundIEType = [["线下预付款", "RECHARGE"], ["在线预付款", "ONLINE_RECHARGE"],
        ["驳回退款", "C_REJECT_FEE"], ["报关费扣款", "DC_PAY"]];
    var balance = "${balance}";
    var formSetting = {
        title: "资金流水",
        module: 'query',
        numCount: '3',
        columns: [{
            index: "BILLNO",
            name: "billNo",
            label: "业务编号"
        }, {
            index: "financialType",
            name: "financialType",
            type: "dropdown",
            data: allFundFinancialType,
            label: "收支类型",
            op: "eq"
        }, {
            index: "ietype",
            name: "ietype",
            type: "dropdown",
            data: allFundIEType,
            label: "账务类型",
            op: "eq"
        }, {
            index: "REGDATE",
            name: "regDate",
            type: "date",
            label: "出入账时间起",
            op: "ge"
        }, {
            index: "REGDATE",
            name: "regDate",
            label: "出入账时间止",
            type: "date",
            op: "le"
        }],
        buttons: {
            custom: [{
                id: "back",
                value: "返回",
                click: function () {
                    history.back();
                }
            }]
        },
        grid: {
            id: "dataGrid",
            title: "资金明细列表：账户余额（元）￥<fmt:formatNumber type='number' value='${balance}' pattern='0.00' maxFractionDigits='2'/><a style='color:blue;margin-left:10px;' href=\"javascript:{ajaxLoader.ajaxPost('ajustment-refreshFund',{},function(){window.history.go(0)})}\">[刷新余额]</a>",
            url: "flow-findList",
            colModel: [{
                index: "id",
                name: "id",
                label: "id",
                hidden: true
            }, {
                index: "billno",
                name: "billNo",
                label: "业务编号"
            }, {
                index: "financialType",
                name: "financialType",
                label: "收支类型"
            }, {
                index: "ietype",
                name: "ietype",
                label: "账务类型"
            }, {
                index: "amount",
                name: "amount",
                label: "金额(元)"
            }, {
                index: "balance",
                name: "balance",
                label: "账户结余(元)"
            }, {
                index: "regDate",
                name: "regDate",
                formatter: 'date',
                formatoptions: {
                    srcformat: 'y-m-d H:i:s',
                    newformat: 'm-d H:i:s'
                },
                label: "出入账时间"
            }],
            sortname: "regDate",
            sortorder: "desc",
            jsonReader: {
//                root: "datas"
            },
            loadComplete: function (data) {
                $("td[aria-describedby='dataGrid_financialType']").each(function () {
                    if ($(this).text() == 'IN' && $(this).next().text() == 'C_REJECT_FEE') {
                        $(this).text('退款');
                    }
                    else if ($(this).text() == 'IN') {
                        $(this).text('预付款')
                    }
                    else {
                        $(this).text(stateUtil.get(allFundFinancialType, $(this).text()));
                    }
                });
                $("td[aria-describedby='dataGrid_ietype']").each(function () {
                    $(this).text(stateUtil.get(allFundIEType, $(this).text()));
                });
            }
        }
    };
    $(document).ready(function () {
        $("#dataTable").mrdForm(formSetting);
    });
    var stateUtil = {
        get: function (arras, key) {
            for (var a in arras) {
                if (arras[a][1] == key) {
                    return arras[a][0];
                }
            }
        }
    }
</script>
<body>
<div id="dataTable"></div>
</body>
</html>
